﻿namespace prime_number
{
    internal class Program
    {
        /// <summary>
        /// 从最大的数开始循环，从上至下开始循环，得到第一个满足条件的质数后直接输出结果，结束循环
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            DateTime begintime = DateTime.Now;
            for (int i = 100000; i > 0; i--)
            {
                int j = 2;
                while (i % j != 0)
                {
                    j++;
                }
                if (i == j)
                {
                    Console.WriteLine($"最大质数为{i}");
                    break;
                }
                
            }
            DateTime endtime = DateTime.Now;
            TimeSpan Time = endtime.Subtract(begintime);
            Console.WriteLine("用时{0}", Time.TotalSeconds);

        }
    }
}